﻿var zombies = zombies || {};

zombies.Media = function (item) {
    var self = this;
    self.MediaId = item.MediaId;
    self.MediaLink = item.MediaLink;
};

zombies.Advertise = function (item) {
    var self = this;
    self.AdvId = item.AdvId;
    self.PubId = item.PubId;
    self.ShortDes = item.ShortDes;
    self.ProductName = item.ProductName;
    self.Title = item.Title;
    self.PreviewImg = item.PreviewImg;
    self.Description = item.Description;
    self.Views = item.Views;
    self.RateSum = item.RateSum;
    self.RateCount = item.RateCount;
    self.Likes = item.Likes;
    self.DateCreated = item.DateCreated;
    self.CompanyName = item.CompanyName;
    self.Name = item.Name;
    var tmp = item.RateCount === 0 ? 1 : item.RateCount;
    self.Rate = item.RateSum / tmp;
};

zombies.Category = function (item) {
    var self = this;
    self.CatId = item.CatId;
    self.Name = item.Name;
    self.Description = item.Description;
    self.IconPath = item.IconPath;
};

zombies.Member = function (item) {
    var self = this;
    self.MemId = item.MemId;
    self.UserName = item.UserName;
    self.FirstName = item.FirstName;
    self.LastName = item.LastName;
    self.Gender = item.Gender;
    self.Email = item.Email;
    self.Level = item.Level;
    self.Point = item.Point;
    self.CMND = item.CMND;
};
zombies.Publisher = function (item) {
    var self = this;
    self.PubId = item.PubId;
    self.UserName = item.UserName;
    self.Email = item.Email;
    self.AvailableDate = item.AvailableDate;
    self.AvailableDateDisplay = moment(item.AvailableDate).format('LLL');
    self.ExpriedDate = item.ExpriedDate;
    self.ExpriedDateDisplay = moment(item.ExpriedDate).format('LLL');
    self.CompanyName = item.CompanyName;
    self.CompanyDes = item.CompanyDes;
    self.CMND = item.CMND;
    self.LogoLink = item.LogoLink;
    self.Facebook = item.Facebook;
};

zombies.Product = function (item) {
    var self = this;
    self.PId = item.PId;
    self.Name = item.Name;
    self.Description = item.Description;
    self.Score = item.Score;
    self.ProductImg = item.ProductImg;
    self.Quantity = item.Quantity;
}

zombies.MediaType = function (item) {
    var self = this;
    self.MediaTypeId = item.MediaTypeId;
    self.Name = item.Name;
    self.Description = item.Description;
    self.IconPath = item.IconPath;
    self.Mime = item.Mime;
};

zombies.Admin = function (item) {
    var self = this;
    self.AdId = item.AdId;
    self.UserId = item.UserId;
    self.UserName = item.UserName;
    self.Email = item.Email;
    self.CreateDate = moment(item.CreateDate).format("dddd, MMMM D, YYYY");
    self.ImgUrl = item.ImgUrl;
};

zombies.Comment = function (item) {
    var self = this;
    self.CommentId = item.CommentId;
    self.Name = item.Name;
    self.Content = item.Content;
    self.DateComment = item.DateComment;
    self.Type = item.Type;
    self.Id = item.Id;
    self.ParentId = item.ParentId;
    self.Spam = item.Spam;
    self.Hide = item.Hide;
    self.Avatar = item.Avatar === null ? '../Advertise/DefaultAssets/v_avatar.png' : item.Avatar;
    self.Title = item.Title;
    self.AdvId = item.AdvId;
};

zombies.User = function (item) {
    var self = this;
    self.UserName = item.UserName;
    self.CreateDate = item.CreateDate;
    self.Type = item.Type;
    self.Avatar = item.Avatar === null ? '../Advertise/DefaultAssets/v_avatar.png' : item.Avatar;
}

zombies.Statistic_VLH = function (item) {
    var self = this;
    self.MonthName = item.MonthName;
    self.Views = item.Views === null ? 0 : item.Views;
    self.Likes = item.Likes === null ? 0 : item.Likes;
    self.Hits = item.Hits;
}

zombies.Statistic_Details = function (item) {
    var self = this;
    self.DateVal = item.DateVal;
    self.Views = item.Views === null ? 0: item.Views;
    self.Likes = item.Likes === null ? 0 : item.Likes;
    self.Ads = item.Ads === null ? 0 : item.Ads;
    self.Hits = item.Hits === null ? 0 : item.Hits;
    self.Users = item.Users === null ? 0 : item.Users;
}

zombies.Subcriber = function (item) {
    var self = this;
    self.MemId = item.MemId;
    self.Name = item.Name;
    self.DateSubcribe = moment(item.DateSubcribe).format("dddd, DD/MM/YYYY");
    self.Avatar = item.Avatar === null ? '../Advertise/DefaultAssets/v_avatar.png' : item.Avatar;
}

zombies.Order = function (item) {
    var self = this;
    self.OrderId = item.OrderId;
    self.DateExchange = item.DateExchange;
    self.MemId = item.MemId;
    self.UserName = item.UserName;
    self.Status = item.Status;
    if (item.Status == 0) {
        self.ImgUrl = "..\\Advertise\\OrderIcon\\Pending.jpg";
    } else if (item.Status == 1) {
        self.ImgUrl = "..\\Advertise\\OrderIcon\\Delivery.jpg";
    } else {
        self.ImgUrl = "..\\Advertise\\OrderIcon\\Cancel.jpg";
    }
    self.DateExchangeDisplay = moment(item.DateExchange).format('LLL');
    self.OrderDetail = [];
    $.each(item.OrderDetail, function (idx, items) {
        self.OrderDetail.push(new zombies.OrderDetail(items));
    });

};

zombies.OrderDetail = function (item) {
    var self = this;
    self.ExLogId = item.ExLogId;
    self.OrderId = item.OrderId;
    self.PId = item.PId;
    self.Name = item.Name;
    self.ProductImg = item.ProductImg;
    self.Score = item.Score;
    self.QuantityToOrder = item.QuantityToOrder;
};